package com.zhl.inner_class3;

public class Test {
    public static void main(String[] args) {
        //目标：掌握匿名的常见使用场景
//        Swimming s = new Swimming() {
//            @Override
//            public void swim() {
//                System.out.println("我是一只小猫，正在游泳...");
//            }
//        };
//        joinSwimming(s);

        joinSwimming(new Swimming() {public void swim() {
            System.out.println("我是一只小猫，正在游泳...");

        }});



    }
    //设计一个方法，可以接收swimming接口的一切实现类对象进来参加游泳比赛
    public static void joinSwimming(Swimming s) {
        System.out.println("欢迎参加游泳比赛！");
        s.swim();
    }


}





//猫狗都要参加游泳比赛
interface Swimming {
    void swim();
}


